<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *打卡记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'城市可选车型'),
);
if($_RQ['op']=='list'){
	$type=intval($_RQ['type']);
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['cityname'])){
		$params2=array('uniacid'=>$_SESSION['uniacid']);
		$params2['name like']='%'.trim($_RQ['cityname']).'%';
		$city_ids=pdo_getall('jy_huolala_city',$params2,'city_id','city_id');
		$params['city_id']=$city_ids?array_keys($city_ids):-1;
		$return['params']['cityname']=$_RQ['cityname'];
	}
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_huolala_che',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$item['city']=pdo_get('jy_huolala_city',array('uniacid'=>$_SESSION['uniacid'],'city_id'=>$item['city_id']));
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'name','title'=>'车型名称','type'=>'string'),
			array('name'=>'order_vehicle_id','title'=>'车型ID','type'=>'string'),
			array('name'=>'city.name','title'=>'所属城市','type'=>'string'),
			array('name'=>'img_url_high_light','title'=>'车型图片','type'=>'image'),
			array('name'=>'carriage_length_cm','title'=>'车型体积长度','type'=>'string'),
			array('name'=>'carriage_width_cm','title'=>'车型体积宽度','type'=>'string'),
			array('name'=>'carriage_height_cm','title'=>'车型体积高度','type'=>'string'),
			array('name'=>'vehicle_price_text_item.start_price_fen','title'=>'起步价格','type'=>'string'),
			array('name'=>'vehicle_price_text_item.start_distance_km','title'=>'起步里程数','type'=>'string'),
			array('name'=>'vehicle_price_text_item.price_fen_after_start','title'=>'超出每公里收费价格(分)','type'=>'string'),
			array('name'=>'vehicle_price_text_item.text_size','title'=>'订单车型长*宽*高','type'=>'string'),
			array('name'=>'vehicle_price_text_item.text_volume','title'=>'订单车型体积','type'=>'string'),
			array('name'=>'vehicle_price_text_item.text_weight','title'=>'订单车型最大载重','type'=>'string'),
		)),
		'search'=>array(
			array('name'=>'name','width'=>15,'title'=>'车型名称','type'=>'string'),
			array('name'=>'cityname','width'=>15,'title'=>'所属城市','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_huolala_che',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
